﻿using AutoMapper;
using B.S.DataBase.MyProject.Domain;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using B.S.DataBase.MyRead.API.Appicant.Command.Approval;
using MediatR;

namespace B.S.DataBase.MyRead.API.Appicant.CommandHandler.Approval
{


    public class FanTianRecordCommendHandlers : IRequestHandler<FanTianRecordCommends, APIResult<List<Record>>>
    {


        private readonly IBaseRepository<Record> recordRepository;

        private readonly IMapper mapper;

        public FanTianRecordCommendHandlers(IBaseRepository<Record> recordRepository, IMapper mapper)
        {
            this.recordRepository = recordRepository;
            this.mapper = mapper;
        }





        /// <summary>
        /// 获取记录表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<APIResult<List<Record>>> Handle(FanTianRecordCommends request, CancellationToken cancellationToken)
        {
            APIResult<List<Record>> result = new APIResult<List<Record>>();
            result.Code = APIEnum.查询成功;
            result.Msg = APIEnum.查询成功.ToString();

            var list = recordRepository.GetAll().Where(x => x.ApplicationId == request.ApplicationId);
            result.data = list.ToList();
            return await Task.FromResult(result);
        }
    }
}
